import { IsOptional, IsString, IsBoolean, IsArray, IsUUID } from 'class-validator'
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'

/**
 * 文件上传DTO
 * 用于接收文件上传时的元数据信息
 */
export class UploadFileDto {
  @ApiPropertyOptional({
    description: '文件描述',
    example: '这是一个重要的文档文件',
  })
  @IsOptional()
  @IsString()
  description?: string

  @ApiPropertyOptional({
    description: '文件标签',
    example: ['文档', '重要', '项目A'],
    type: [String],
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  tags?: string[]

  @ApiPropertyOptional({
    description: '是否公开访问',
    example: false,
    default: false,
  })
  @IsOptional()
  @IsBoolean()
  isPublic?: boolean

  @ApiPropertyOptional({
    description: '可读权限用户ID列表',
    example: [1, 2],
    type: [Number],
  })
  @IsOptional()
  @IsArray()
  readPermissions?: number[]

  @ApiPropertyOptional({
    description: '可写权限用户ID列表',
    example: [1, 2],
    type: [Number],
  })
  @IsOptional()
  @IsArray()
  writePermissions?: number[]

  @ApiPropertyOptional({
    description: '可删除权限用户ID列表',
    example: [1, 2],
    type: [Number],
  })
  @IsOptional()
  @IsArray()
  deletePermissions?: number[]
}

/**
 * 文件上传响应DTO
 */
export class UploadFileResponseDto {
  @ApiProperty({
    description: '文件ID',
    example: 1,
  })
  id: number

  @ApiProperty({
    description: '原始文件名',
    example: 'document.pdf',
  })
  originalName: string

  @ApiProperty({
    description: '存储文件名',
    example: '550e8400-e29b-41d4-a716-446655440000.pdf',
  })
  filename: string

  @ApiProperty({
    description: '文件大小（字节）',
    example: 1024000,
  })
  size: number

  @ApiProperty({
    description: 'MIME类型',
    example: 'application/pdf',
  })
  mimeType: string

  @ApiProperty({
    description: '文件访问URL',
    example: 'http://localhost:3000/files/550e8400-e29b-41d4-a716-446655440000.pdf',
  })
  url: string

  @ApiProperty({
    description: '文件状态',
    example: 'completed',
    enum: ['pending', 'uploaded', 'processing', 'completed', 'error'],
  })
  status: string
}
